<template>
  <view>
    <image :src="v.image" mode="" style="width: 100%"></image>
    <view class="title">{{ v.title }}</view>
    <view class="desc">{{ v.desc }}</view>
    <view class="">
      单价：{{v.price}}--类型：{{v.type}}--距离：{{v.distance}}
    </view>
    <button @click="message">资讯管家</button>
    <canvas style="width: 200px; height: 200px;" canvas-id="myQrcode"></canvas>
  </view>
</template>

<script>
  import drawQrcode from 'weapp-qrcode'
  export default {
    onLoad({
      id
    }) {
      this.id = id;
      this.getDetail()
    },
    data() {
      return {
        id: '',
        v: {}
      };
    },
    methods: {
      async getDetail() {
        const {
          data: v
        } = await uni.request({
          url: 'http://localhost:3000/list/' + this.id
        })
        this.v = v
      },
      async message() {
        // const resp1 = await uni.request({
        //   url: 'https://api.weixin.qq.com/cgi-bin/token',
        //   data: {
        //     grant_type: 'client_credential',
        //     appid: 'wx2bae7e5b372f752d',
        //     secret: '8f852a22f1667b444576c9695887952f'
        //   }
        // })
        // console.log(resp1)
        // // 二维码
        // const resp = await uni.request({
        //   url: 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=' + resp1.data.access_token,
        //   methods: 'POST',
        //   data: {
        //     path: 'pages/home/home',
        //     access_token: resp1.data.access_token
        //   }
        // })
        // console.log(resp)

        drawQrcode({
          width: 200,
          height: 200,
          canvasId: 'myQrcode',
          text: 'https://www.baidu.com'
        })
      }
    }
  }
</script>

<style lang="scss">

</style>
